<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2016-6-21
 * Func   网站设置
 */
defined('IN_YuLin') || exit('NO PERMIT!');

$table = Table('web_setting');

if(IS_POST)
{
    $id = intval($_REQUEST['id']);
    $data = $id ? $db->getrow('SELECT * FROM '.$table.' WHERE id = '.$id) : [];

    //  表单数据
    $post = $_POST['data'];

    $ins = [];
    $ins['title']	=   NoBadStr($post['title']);
    $ins['keyword']	=   NoBadStr($post['keyword']);
    $ins['summary']	=   $post['summary'];
    $ins['tel']		=   $post['tel'];
    $ins['qq']		=   NoBadStr($post['qq']);
    $ins['address']	=   NoBadStr($post['address']);

    if($data['id'])
	{
        $db->exec('UPDATE '.$table.' SET '.CreateUpdateSql($ins).' WHERE id = '.$data['id']);
    }
	else
	{
        $db->exec('INSERT INTO '.$table.CreateInsertSql($ins));
    }
    AjaxReturn(['error'=>'0','msg'=>'操作成功']);
}

$data = $db->getrow('SELECT * FROM '.$table.' ORDER BY id DESC');

$tpl->display($m.'/setting');